<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
   <title>注册</title>
   <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
   <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
  <style>
	.table th{
		text-align:center;
	}
	.table td{
		text-align:center;
	}
	#left{
		width:20%;
		float:left;
	}
	#content{
		width:80%;
		margin-left:20%;
	}
	#info{
		font-size:20px;
	}
	 #pageButton{
			width:80%;
			margin-left:10%;
	   }
	   #right{
			margin-left:50%;
			
	   }
  </style>
</head>
<?php require_once("declogin.php");?>
<body>
	<nav class="navbar navbar-inverse" role="navigation">
   <div class="navbar-header">
      <a class="navbar-brand" id="info">FishVideo 信息管理平台</a>
   </div>
		
    <ul class="nav navbar-nav navbar-right">
	<li><a>欢迎你<?php  echo $_SESSION['adminname']?>&nbsp&nbsp&nbsp&nbsp</a></li>
     </ul>
	  
</nav>
	<div class="container" id=left>
	<?php require_once("menu.html"); ?>
	</div>
		<?php
		
				require_once("../utils/upload.php");
				require_once("../utils/db.php");
				$conn=connect();
				$realpath="../user/upload/";
			if(isset($_POST['changeUser'])){//修改
				
				$hob=implode($_POST['like'],",");
				//echo $hob;
				$sql="update fishvideo_users set yjl_uname='{$_POST['name']}',yjl_sex='{$_POST['sex']}',
				yjl_birthdate='{$_POST['bir']}',yjl_hobby='{$hob}',yjl_degree='{$_POST['xl']}',
				yjl_intro='{$_POST['zwjs']}'";
				
				//var_dump($_POST);
				if(isset($_FILES['tx']) && $_FILES['tx']['size']!=0){
					$pic_path=GetPic("tx",$realpath,"0");
					$sql.=",yjl_pic='{$pic_path}'";
					unlink($realpath.$_POST['ypic']);
				}	
			    $sql.=" where yjl_uid='{$_POST['uid']}'";
				//	echo $sql;
				mysql_query($sql,$conn);
				$num=mysql_affected_rows($conn);
				//echo $num;
				$url="";
				if($num<1){
					echo "<script>alert('修改失败！');</script>";
					$url="doUpdateUser.php";
				}else{
					echo "<script>alert('修改成功！');</script>";
					$url="control_user.php";
				}
				echo "<meta http-equiv='Refresh' content='0;URL={$url}'>"; //跳转界面
			}
			//显示所有
			$sql="select * from fishvideo_users";
			$result=mysql_query($sql,$conn);
			$row=mysql_fetch_array($result);
		?>
	<div id="content">
		<br>
		<form role="form"  method="post" enctype="multipart/form-data">
		<table class="table" align="center">
		<input type="hidden" name="uid" value=<?php
			echo "'{$row['yjl_uid']}'";
		?>>
		<input type="hidden" name="ypic" value=<?php
				echo "'{$row['yjl_pic']}'";
		?>>
		
		<tr><th>姓名</th><td><input type="text" class="form-control" id="name" name="name"
		required oninvalid="setCustomValidity('请填写姓名')"
					oninput="setCustomValidity('')" value=<?php
			echo "'{$row['yjl_uname']}'";
		?> ></td></tr>
		<tr><th>性别</th>
		<td colspan="2">
		<input type="radio"  name="sex" value="0"
		<?php
			if($row['yjl_sex']==0)
			echo "checked";
		?>>男
		<input type="radio"  name="sex" value="1"
		 <?php
			if($row['yjl_sex']==1)
			echo "checked";
		?>>女</td></tr>
		<tr><th>生日</th><td><input type="date" id="bir" name="bir" class="form-control"
		 value=<?php
			echo "'{$row['yjl_birthdate']}'";
		?>></td></tr>
		<tr><th>爱好</th>
		<td colspan="5">
		<input type="checkbox" name="like[]"  value="旅游"
		 <?php
			if(strstr($row['yjl_hobby'],'旅游'))
			echo "checked";
		?> >旅游</radio>
		<input type="checkbox" name="like[]" value="登山" 
		 <?php
			if(strstr($row['yjl_hobby'],'登山'))
			echo "checked";
		?> >登山</radio>
		<input type="checkbox" name="like[]" value="健身"
		  <?php
			if(strstr($row['yjl_hobby'],'健身'))
			echo "checked";
		?>>健身</radio>
		<input type="checkbox" name="like[]" value="上网" 
		 <?php
			if(strstr($row['yjl_hobby'],'上网'))
			echo "checked";
		?>>上网</radio>
		<input type="checkbox" name="like[]" value="游泳" 
		 <?php
			if(strstr($row['yjl_hobby'],'游泳'))
			echo "checked";
		?>>游泳</radio>
		</td></tr>
		<tr>
		<th>学历</th>
		<td>
		<select name="xl" class="form-control" required oninvalid="setCustomValidity('请选择学历')"
					oninput="setCustomValidity('')">
		  <option  disabled >请选择</option>
		  <option value ="0" <?php
			if($row['yjl_degree']==0)
			echo "selected";
		?> >高中</option>
		  <option value ="1" <?php
			if($row['yjl_degree']==1)
			echo "selected";
		?> >大学</option>
		  <option value="2" <?php
			if($row['yjl_degree']==2)
			echo "selected";
		?> >研究生</option>
		  <option value="3" <?php
			if($row['yjl_degree']==3)
			echo "selected";
		?> >博士</option>
		</select>
		</td>
		</tr>
		<tr>
		<th>自我介绍</th><td><textarea name="zwjs" class="form-control" rows="3" cols="20"
		placeholder="性格，习惯...."> <?php  echo $row['yjl_intro'];?> </textarea></td>
		</tr>
		<tr>
		
		<th>头像</th><td><img width="60px" height="60px" src=<?php echo "{$realpath}{$row['yjl_pic']}"; ?> ></td>
		</tr>
		<tr>
		<th>上传新头像</th><td><input type="file" name="tx" class="form-control" ></td>
		</tr>
	</table>
	<div id="pageButton">
		<span id="right">
            <button type="submit" name="changeUser" class="btn btn-primary" style='width:120px'>
               修改
            </button>
		</span>
    </div>
	 </form>
	 </div>
</body>
</html>